#!/bin/bash
rm -rf $(pwd)/x265/build/android
rm -rf $(pwd)/build

mkdir x265/build/android
cp -rf build_script/* x265/build/android

export NDK_ROOT=/home/snake/Android/android-ndk-r21e # 换成自己的实际 NDK 路径
export ANDROID_API_VERSION=21
export NUMBER_OF_CORES=4
export OUTPUT_PREFIX=$(pwd)/build

pushd x265/build/android/armeabi-v7a
bash build.sh
popd

pushd x265/build/android/arm64-v8a
bash build.sh
popd


cmake ../../../source \
  -DCMAKE_SYSTEM_NAME=Android \
  -DCMAKE_SYSTEM_VERSION=${ANDROID_API_VERSION} \
  -DCMAKE_ANDROID_ARCH_ABI=armeabi-v7a \
  -DCMAKE_ANDROID_NDK=${NDK_ROOT} \
  -DCMAKE_ANDROID_STL_TYPE=c++_static \
  -DNEON_ANDROID=1

sed -i 's/-lpthread/-pthread/g' CMakeFiles/cli.dir/link.txt
sed -i 's/-lpthread/-pthread/g' CMakeFiles/x265-shared.dir/link.txt
sed -i 's/-lpthread/-pthread/g' CMakeFiles/x265-static.dir/link.txt

make -j${NUMBER_OF_CORES}
make DESTDIR=${OUTPUT_PREFIX}/armeabi-v7a install




cmake ../../../source \
  -DCMAKE_SYSTEM_NAME=Android \
  -DCMAKE_SYSTEM_VERSION=${ANDROID_API_VERSION} \
  -DCMAKE_ANDROID_ARCH_ABI=arm64-v8a \
  -DCMAKE_ANDROID_NDK=${NDK_ROOT} \
  -DCMAKE_ANDROID_STL_TYPE=c++_static \
  -DNEON_ANDROID=1

sed -i 's/-lpthread/-pthread/g' CMakeFiles/cli.dir/link.txt
sed -i 's/-lpthread/-pthread/g' CMakeFiles/x265-shared.dir/link.txt
sed -i 's/-lpthread/-pthread/g' CMakeFiles/x265-static.dir/link.txt

make -j${NUMBER_OF_CORES}
make DESTDIR=${OUTPUT_PREFIX}/arm64-v8a install





































